import java.util.Arrays;

public class MyStack {
    private int[] elem;
    private int Usedsize;

    private static final int DEFAULT_CAPACITY = 10;

    public MyStack() {
        this.elem = new int[DEFAULT_CAPACITY];//elem.length
    }
    public boolean is_Full(){
        if(Usedsize == elem.length){
            return true;
        }
        return false;
    }
    public void push(int val){
        if(is_Full()){
            Arrays.copyOf(this.elem,2*elem.length);
        }
        elem[Usedsize] = val;
        Usedsize++;
    }
    public boolean isEmpty(){
        return Usedsize == 0;
    }
    public int pop(){
        if(isEmpty()){
            throw new NullStackException("栈中没有元素");
        }
        int beforesize = Usedsize - 1;
        Usedsize--;
        return elem[beforesize];
    }
    public int peek(){
        if(isEmpty()){
            throw new NullStackException("栈中没有元素");
        }
        return elem[Usedsize-1];
    }
}
